WM4_Gary_Rogers_JS2_Week_1#106
Conversation
|
|
||
| let myCountry = "UnitedKingdom"; | ||
| let myCapitalCity; // complete the code | ||
| let myCapitalCity = "London" |
There was a problem hiding this comment.
|
|
||
| // write code here | ||
|
|
||
| let topPlayers = ["Michael Jordan", "Scottie Pippen", "Dennis Rodman"]; |
There was a problem hiding this comment.
You should not copy the code but use the dot notation or bracket notation to retrieve values from the object.
Please check this:
https://codeburst.io/javascript-quickie-dot-notation-vs-bracket-notation-333641c0f781
https://syllabus.codeyourfuture.io/js-core-2/week-1/lesson#objects
| population: 9750000, | ||
| } | ||
| }; | ||
| capitalCities.UnitedKingdom = 8980000; |
There was a problem hiding this comment.
The part related to: "Change the value of UnitedKingdom's capital city population to 8980000." You did well :)
You need to do the same way the other part of the exercise:
- Add the property for population to China's capital city and set the value to 21500000.
- Add the country "Peru" to capitalCities object.
- Add a name of "Lima" to Peru's capital city.
- Add a population of 9750000 to Peru's capital city.
Please check this: https://bobbyhadz.com/blog/javascript-add-key-value-pair-to-object
|
|
||
| // write code here | ||
|
|
||
| let student = { |
There was a problem hiding this comment.
Please use bracket notation here - the exercise needs to be done dynamically, not hard coded.
| }; | ||
|
|
||
| console.log(myPet.getName()); | ||
| console.log(myPet.getName()); //has attempted to create a function element where the property should be// |
There was a problem hiding this comment.
Please check what is missing in the function.
This is quite interesting post about it: https://stackoverflow.com/questions/17337064/does-every-javascript-function-have-to-return-a-value
| }; | ||
|
|
||
| sayHelloToUser(user); | ||
| sayHelloToUser(user); //Hello in the console log is undefined, as well as 'firstName' not identified as the object 'name'// |
There was a problem hiding this comment.
Please check one more time what parameters have the user object.
| }; | ||
|
|
||
| console.log(car["colour"]); | ||
| console.log(car["colour"]); //"colour" is not defined as an object anywhere in the variable statement// |
There was a problem hiding this comment.
Please check the CYF lesson about objects: https://syllabus.codeyourfuture.io/js-core-2/week-1/lesson#objects
| let student = { | ||
| // write code here | ||
| } | ||
| name: "Daniel", |
There was a problem hiding this comment.
Please think about the object's methods as functions because basically, they are functions.
You need to finish this exercise in a dynamic way.
Please check this: https://syllabus.codeyourfuture.io/js-core-1/week-1/lesson#functions
| } | ||
| let currencyCodes = {}; | ||
| countryCurrencyCodes.forEach((element) => | ||
| currencyCodes[0] = element[1] |
There was a problem hiding this comment.
Here is a small thing to fix the end of the entire exercise will be done perfectly! 👍
Please think over where You can use bracket notation in the line 23.
Pat-On
left a comment
There was a problem hiding this comment.
You are close to understanding key topics from these exercises. Please check the materials that I attached in the comments :)
From the mandatory exercise, You need to change one thing to have completely done exercise 2. Great 👍
Please finish mandatory 2 and 3
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?